package com.xk.service.impl;

import com.xk.mapper.TeacherMapper;
import com.xk.mapper.UserMapper;
import com.xk.pojo.User;
import com.xk.service.UserService;
import com.xk.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;

    @Override
    public boolean checklogin(User user) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        userMapper = sqlSession.getMapper(UserMapper.class);
        boolean checklogin = userMapper.checklogin(user);
        sqlSession.commit();
        sqlSession.close();
        return checklogin;
    }

    @Override
    public int addUser(User user) {
        SqlSession sqlSession = MyBatisUtils.getSqlSession();
        userMapper = sqlSession.getMapper(UserMapper.class);
        int i = userMapper.addUser(user);
        sqlSession.commit();
        sqlSession.close();
        return i;
    }
}
